﻿<!-- Copyright 2012-2017 Dmitry Kischenko

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. -->
<ribbon:RibbonWindow x:Class="xFunc.Views.MainView"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:res="clr-namespace:xFunc.Resources"
                    xmlns:ribbon="clr-namespace:Fluent;assembly=Fluent"
                    xmlns:viewModels="clr-namespace:xFunc.ViewModels"
                    xmlns:views="clr-namespace:xFunc.Views"
                    Foreground="White"
                    Title="xFunc" Width="1024" Height="576" MinWidth="480" MinHeight="270"
                    Icon="../Images/xFunc.ico" TextOptions.TextFormattingMode="Display">
    <ribbon:RibbonWindow.CommandBindings>
        <CommandBinding Command="views:MainView.NewCommand" Executed="NewCommand_Execute" />
        <CommandBinding Command="views:MainView.OpenCommand" Executed="OpenCommand_Execute" />
        <CommandBinding Command="views:MainView.SaveCommand" Executed="SaveCommand_Execute" />
        <CommandBinding Command="views:MainView.SaveAsCommand" Executed="SaveAsCommand_Execute" />

        <CommandBinding Command="views:MainView.AutoFormatCommand" Executed="AutoButton_Execute" CanExecute="FormatButtons_CanExecute" />
        <CommandBinding Command="views:MainView.NormalFormatCommand" Executed="NormalButton_Execute" CanExecute="FormatButtons_CanExecute" />
        <CommandBinding Command="views:MainView.ExponentialFormatCommand" Executed="ExponentialButton_Execute" CanExecute="FormatButtons_CanExecute" />

        <CommandBinding Command="views:MainView.DegreeCommand" Executed="DegreeButton_Execute" CanExecute="AngleButtons_CanExecute" />
        <CommandBinding Command="views:MainView.RadianCommand" Executed="RadianButton_Execute" CanExecute="AngleButtons_CanExecute" />
        <CommandBinding Command="views:MainView.GradianCommand" Executed="GradianButton_Execute" CanExecute="AngleButtons_CanExecute" />

        <CommandBinding Command="views:MainView.BinCommand" Executed="BinCommand_Execute" CanExecute="BaseCommands_CanExecute" />
        <CommandBinding Command="views:MainView.OctCommand" Executed="OctCommand_Execute" CanExecute="BaseCommands_CanExecute" />
        <CommandBinding Command="views:MainView.DecCommand" Executed="DecCommand_Execute" CanExecute="BaseCommands_CanExecute" />
        <CommandBinding Command="views:MainView.HexCommand" Executed="HexCommand_Execute" CanExecute="BaseCommands_CanExecute" />

        <CommandBinding Command="views:MainView.DeleteExpCommand" Executed="DeleteExp_Execute" CanExecute="DeleteExp_CanExecute" />
        <CommandBinding Command="views:MainView.ClearCommand" Executed="Clear_Execute" CanExecute="Clear_CanExecute" />

        <CommandBinding Command="views:MainView.VariablesCommand" Executed="VariablesCommand_Execute" CanExecute="VariablesCommand_CanExecute" />
        <CommandBinding Command="views:MainView.FunctionsCommand" Executed="FunctionsCommand_Execute" CanExecute="FunctionsCommand_CanExecute" />
        <CommandBinding Command="views:MainView.ConverterCommand" Executed="ConverterCommand_Execute" />

        <CommandBinding Command="views:MainView.AboutCommand" Executed="AboutCommand_Execute" />
        <CommandBinding Command="views:MainView.SettingsCommand" Executed="SettingsCommand_Execute" />
        <CommandBinding Command="views:MainView.ExitCommand" Executed="ExitCommand_Execute" />
    </ribbon:RibbonWindow.CommandBindings>
    <ribbon:RibbonWindow.InputBindings>
        <KeyBinding Command="views:MainView.NewCommand" Key="N" Modifiers="Control" />
        <KeyBinding Command="views:MainView.OpenCommand" Key="O" Modifiers="Control" />
        <KeyBinding Command="views:MainView.SaveCommand" Key="S" Modifiers="Control" />
        <KeyBinding Command="views:MainView.SaveAsCommand" Key="S" Modifiers="Control+Shift" />

        <KeyBinding Command="views:MainView.DegreeCommand" Key="D" Modifiers="Control+Alt" />
        <KeyBinding Command="views:MainView.RadianCommand" Key="R" Modifiers="Control+Alt" />
        <KeyBinding Command="views:MainView.GradianCommand" Key="G" Modifiers="Control+Alt" />

        <KeyBinding Command="views:MainView.DeleteExpCommand" Key="Delete" />
        <KeyBinding Command="views:MainView.ClearCommand" Key="Delete" Modifiers="Shift" />

        <KeyBinding Command="views:MainView.VariablesCommand" Key="V" Modifiers="Control+Alt" />
        <KeyBinding Command="views:MainView.FunctionsCommand" Key="F" Modifiers="Control+Alt" />
        <KeyBinding Command="views:MainView.ConverterCommand" Key="C" Modifiers="Control+Alt" />

        <KeyBinding Command="views:MainView.AboutCommand" Key="F1" />
        <KeyBinding Command="views:MainView.SettingsCommand" Key="S" Modifiers="Alt" />
        <KeyBinding Command="views:MainView.ExitCommand" Key="F4" Modifiers="Alt" />
    </ribbon:RibbonWindow.InputBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="230" MinWidth="220" MaxWidth="400" />
        </Grid.ColumnDefinitions>

        <ribbon:Ribbon Grid.Row="0" Grid.ColumnSpan="2">
            <ribbon:Ribbon.QuickAccessItems>
                <ribbon:QuickAccessMenuItem Target="{Binding ElementName=undoButton}" IsChecked="True" />
                <ribbon:QuickAccessMenuItem Target="{Binding ElementName=redoButton}" IsChecked="True" />
            </ribbon:Ribbon.QuickAccessItems>
            <ribbon:Ribbon.ToolBarItems>
                <ribbon:Button Size="Small" Header="{x:Static res:Resource.AboutButtonHeader}" Icon="../Images/Help.png" Command="views:MainView.AboutCommand">
                    <ribbon:Button.ToolTip>
                        <ribbon:ScreenTip Title="{x:Static res:Resource.AboutToolTipTitle}" Text="{x:Static res:Resource.AboutButtonToolTip}" />
                    </ribbon:Button.ToolTip>
                </ribbon:Button>
            </ribbon:Ribbon.ToolBarItems>
            <ribbon:Ribbon.Menu>
                <ribbon:Backstage Header="{x:Static res:Resource.FileMenu}">
                    <ribbon:BackstageTabControl>
                        <ribbon:Button Header="{x:Static res:Resource.NewMenu}" Command="views:MainView.NewCommand" />
                        <ribbon:Button Header="{x:Static res:Resource.OpenMenu}" Command="views:MainView.OpenCommand" />
                        <ribbon:Button Header="{x:Static res:Resource.SaveMenu}" Command="views:MainView.SaveCommand" />
                        <ribbon:Button Header="{x:Static res:Resource.SaveAsMenu}" Command="views:MainView.SaveAsCommand" />
                        <ribbon:SeparatorTabItem />
                        <ribbon:Button Header="{x:Static res:Resource.SettingsMenu}" Command="views:MainView.SettingsCommand">
                            <ribbon:Button.ToolTip>
                                <ribbon:ScreenTip Title="{x:Static res:Resource.SettingsToolTipTitle}" Text="{x:Static res:Resource.SettingsToolTip}" />
                            </ribbon:Button.ToolTip>
                        </ribbon:Button>
                        <ribbon:SeparatorTabItem />
                        <ribbon:Button Header="{x:Static res:Resource.ExitMenu}" Command="views:MainView.ExitCommand">
                            <ribbon:Button.ToolTip>
                                <ribbon:ScreenTip Title="{x:Static res:Resource.ExitToolTipTitle}" Text="{x:Static res:Resource.ExitToolTip}" />
                            </ribbon:Button.ToolTip>
                        </ribbon:Button>
                    </ribbon:BackstageTabControl>
                </ribbon:Backstage>
            </ribbon:Ribbon.Menu>
            <ribbon:RibbonTabItem Header="{x:Static res:Resource.HomeRibbonTabHeader}" ReduceOrder="AnglesGroupBox,AnglesGroupBox,AnglesGroupBox,OutputFormatGroupBox,OutputFormatGroupBox,OutputFormatGroupBox,AnswerBaseGroupBox,AnswerBaseGroupBox,AnswerBaseGroupBox,ToolsGroupBox,ToolsGroupBox,ToolsGroupBox" IsSelected="True">
                <ribbon:RibbonGroupBox Header="{x:Static res:Resource.ClipboardGroupHeader}">
                    <ribbon:Button x:Name="undoButton" Header="{x:Static res:Resource.UndoButtonHeader}" Icon="../Images/Undo.png" LargeIcon="../Images/UndoLarge.png" Command="ApplicationCommands.Undo" FocusManager.IsFocusScope="True">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.UndoScreenTipTitle}" Text="{x:Static res:Resource.UndoScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <ribbon:Button x:Name="redoButton" Header="{x:Static res:Resource.RedoButtonHeader}" Icon="../Images/Redo.png" LargeIcon="../Images/RedoLarge.png" Command="ApplicationCommands.Redo" FocusManager.IsFocusScope="True">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.RedoScreenTipTitle}" Text="{x:Static res:Resource.RedoScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <Separator />
                    <ribbon:Button Header="{x:Static res:Resource.CutButtonHeader}" Icon="../Images/Cut.png" LargeIcon="../Images/CutLarge.png" Command="ApplicationCommands.Cut" FocusManager.IsFocusScope="True">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.CutScreenTipTitle}" Text="{x:Static res:Resource.CutScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <ribbon:Button Header="{x:Static res:Resource.CopyButtonHeader}" Icon="../Images/Copy.png" LargeIcon="../Images/CopyLarge.png" Command="ApplicationCommands.Copy" FocusManager.IsFocusScope="True">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.CopyScreenTipTitle}" Text="{x:Static res:Resource.CopyScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <ribbon:Button Header="{x:Static res:Resource.PasteButtonHeader}" Icon="../Images/Paste.png" LargeIcon="../Images/PasteLarge.png" Command="ApplicationCommands.Paste" FocusManager.IsFocusScope="True">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.PasteScreenTipTitle}" Text="{x:Static res:Resource.PasteScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                </ribbon:RibbonGroupBox>
                <ribbon:RibbonGroupBox x:Name="AnglesGroupBox"  Header="{x:Static res:Resource.AnglesGroupHeader}">
                    <ribbon:ToggleButton x:Name="degreeButton" Header="{x:Static res:Resource.DegreeButtonHeader}" SizeDefinition="Large" Command="views:MainView.DegreeCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Deg</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                        <ribbon:ToggleButton.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.DegreeScreenTipTitle}" Text="{x:Static res:Resource.DegreeScreenTipText}" />
                        </ribbon:ToggleButton.ToolTip>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="radianButton" Header="{x:Static res:Resource.RadianButtonHeader}" SizeDefinition="Large" Command="views:MainView.RadianCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Rad</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                        <ribbon:ToggleButton.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.RadianScreenTipTitle}" Text="{x:Static res:Resource.RadianScreenTipText}" />
                        </ribbon:ToggleButton.ToolTip>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="gradianButton" Header="{x:Static res:Resource.GradianButtonHeader}" SizeDefinition="Large" Command="views:MainView.GradianCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Grad</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                        <ribbon:ToggleButton.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.GradianScreenTipTitle}" Text="{x:Static res:Resource.GradianScreenTipText}" />
                        </ribbon:ToggleButton.ToolTip>
                    </ribbon:ToggleButton>
                </ribbon:RibbonGroupBox>
                <ribbon:RibbonGroupBox x:Name="OutputFormatGroupBox"  Header="{x:Static res:Resource.OutputFormatGroupHeader}">
                    <ribbon:ToggleButton x:Name="autoButton" Header="{x:Static res:Resource.AutoFormatButtonHeader}" SizeDefinition="Large" Command="views:MainView.AutoFormatCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Auto</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="normalButton" Header="{x:Static res:Resource.NormalFormatButtonHeader}" SizeDefinition="Large" Command="views:MainView.NormalFormatCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Normal</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="exponentialButton" Header="{x:Static res:Resource.ExponentialFormatButtonHeader}" SizeDefinition="Large" Command="views:MainView.ExponentialFormatCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Exp</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                </ribbon:RibbonGroupBox>
                <ribbon:RibbonGroupBox x:Name="AnswerBaseGroupBox" Header="{x:Static res:Resource.AnswerBaseGroupHeader}">
                    <ribbon:ToggleButton x:Name="binButton" Header="Binary" SizeDefinition="Large" Command="views:MainView.BinCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Bin</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="octButton" Header="Octal" SizeDefinition="Large" Command="views:MainView.OctCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Oct</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="decButton" Header="Decimal" SizeDefinition="Large" Command="views:MainView.DecCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Dec</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                    <ribbon:ToggleButton x:Name="hexButton" Header="Hexadecimal" SizeDefinition="Large" Command="views:MainView.HexCommand">
                        <ribbon:ToggleButton.LargeIcon>
                            <Viewbox>
                                <TextBlock FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Hex</TextBlock>
                            </Viewbox>
                        </ribbon:ToggleButton.LargeIcon>
                    </ribbon:ToggleButton>
                </ribbon:RibbonGroupBox>
                <ribbon:RibbonGroupBox Header="{x:Static res:Resource.ExpListGroupHeader}">
                    <ribbon:Button Header="{x:Static res:Resource.DeleteExpButtonHeader}" Icon="../Images/Delete.png" LargeIcon="../Images/DeleteLarge.png" Command="views:MainView.DeleteExpCommand">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.DeleteExpScreenTipTitle}" Text="{x:Static res:Resource.DeleteExpScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <ribbon:Button Header="{x:Static res:Resource.ClearButtonHeader}" Icon="../Images/Clear.png" LargeIcon="../Images/ClearLarge.png" Command="views:MainView.ClearCommand">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.ClearScreenTipTitle}" Text="{x:Static res:Resource.ClearScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                </ribbon:RibbonGroupBox>
                <ribbon:RibbonGroupBox x:Name="ToolsGroupBox"  Header="{x:Static res:Resource.ToolsGroupHeader}" Icon="..\Images\Tools.png">
                    <ribbon:Button Header="{x:Static res:Resource.VariablesButtonHeader}" Icon="..\Images\Variable.png" LargeIcon="..\Images\VariableLarge.png" SizeDefinition="Large" Command="views:MainView.VariablesCommand">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.VarScreenTitTitle}" Text="{x:Static res:Resource.VarScreenTitText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <ribbon:Button Header="{x:Static res:Resource.FunctionButtonHeader}" Icon="..\Images\Function.png" LargeIcon="..\Images\FunctionLarge.png" SizeDefinition="Large" Command="views:MainView.FunctionsCommand">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.FuncScreenTitTitle}" Text="{x:Static res:Resource.FuncScreenTitText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                    <ribbon:Button Header="{x:Static res:Resource.ConverterButtonHeader}" Icon="..\Images\Converter.png" LargeIcon="..\Images\ConverterLarge.png" SizeDefinition="Large" Command="views:MainView.ConverterCommand">
                        <ribbon:Button.ToolTip>
                            <ribbon:ScreenTip Title="{x:Static res:Resource.ConverterScreenTipTitle}" Text="{x:Static res:Resource.ConverterScreenTipText}" />
                        </ribbon:Button.ToolTip>
                    </ribbon:Button>
                </ribbon:RibbonGroupBox>
            </ribbon:RibbonTabItem>
        </ribbon:Ribbon>

        <TabControl x:Name="tabControl" Grid.Row="1">
            <TabItem x:Name="mathTab" Header="{x:Static res:Resource.MathTab}">
                <views:MathControl x:Name="mathControl" Status="{Binding Path=Text, ElementName=statusBox, Mode=OneWayToSource}" />
            </TabItem>
            <TabItem x:Name="graphsTab" Header="{x:Static res:Resource.GraphsTab}">
                <views:GraphsControl x:Name="graphsControl" Status="{Binding Path=Text, ElementName=statusBox, Mode=OneWayToSource}" />
            </TabItem>
            <TabItem x:Name="truthTableTab" Header="{x:Static res:Resource.TruthTableTab}">
                <views:TruthTableControl x:Name="truthTableControl" Status="{Binding Path=Text, ElementName=statusBox, Mode=OneWayToSource}" />
            </TabItem>
        </TabControl>

        <GridSplitter Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Width="3" HorizontalAlignment="Left" VerticalAlignment="Stretch" />
        <ScrollViewer Grid.Row="1" Grid.Column="1" Margin="3,0,0,0" Background="White" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <StackPanel.Resources>
                    <Style TargetType="{x:Type Button}" BasedOn="{StaticResource buttonStyle}" />
                </StackPanel.Resources>
                <Expander x:Name="numberToolBar" Header="{x:Static res:Resource.NumberAndArithmeticExpanderHeader}" IsExpanded="True">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="7" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>7</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="8" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>8</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="9" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>9</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="/" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>÷</TextBlock>
                            </Viewbox>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="4" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>4</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="5" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>5</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="6" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>6</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="*" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>×</TextBlock>
                            </Viewbox>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Tag="1" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>1</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Tag="2" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>2</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="2" Tag="3" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>3</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="3" Tag="-" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>&#x2212;</TextBlock>
                            </Viewbox>
                        </Button>

                        <Button Grid.Row="3" Grid.Column="0" Tag="0" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>0</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="3" Grid.Column="1" Tag="." Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>•</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="3" Grid.Column="2" Click="EnterButton_Click">
                            <Viewbox>
                                <TextBlock>=</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="3" Grid.Column="3" Tag="+" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>+</TextBlock>
                            </Viewbox>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="standartMathToolBar" Header="{x:Static res:Resource.StandartExpanderHeader}" IsExpanded="True">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="^2" Click="InsertInv_Click">
                            <Viewbox>
                                <TextBlock>x<Run BaselineAlignment="Top" FontSize="12">2</Run></TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.PowerOfTwoToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="^" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>x<Run BaselineAlignment="Top" FontSize="12">y</Run></TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.PowerOfYToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="sqrt" Click="InsertFunc_Click">
                            <Rectangle Fill="{StaticResource sqrt}" Width="22" Height="16" />
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SquareRootToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="root" Click="InsertDoubleArgFunc_Click">
                            <Rectangle Fill="{StaticResource root}" Width="22" Height="16" />
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.NthRootToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="ln" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>ln(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.LnToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="lg" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>lg(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.LgToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="log" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>log<Run BaselineAlignment="Subscript" FontSize="12">y</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.LogToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="abs" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>|x|</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.AbsToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Tag="fact" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>x!</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.FactToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Tag="round" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>round(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.RoundToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="2" Tag="ceil" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>ceil(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CeilToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="3" Tag="floor" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>floor(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.FloorToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="3" Grid.Column="0" Tag="%" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>%</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ModuleToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="trigonometricToolBar" Header="{x:Static res:Resource.TrigonometricExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="sin" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sin(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SineToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="cos" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>cos(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CosineToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="tan" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>tan(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.TangentToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="cot" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>cot(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CotangentToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="arcsin" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sin<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArcsineToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="arccos" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>cos<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArccosineToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="arctan" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>tan<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArctangentToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="arccot" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>cot<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArccotangentToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Tag="sec" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sec(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SecantToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Tag="csc" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>csc(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CosecantToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="2" Tag="arcsec" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sec<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArcsecantToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="3" Tag="arccsc" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>csc<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArccosecantToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="hyperbolicToolBar" Header="{x:Static res:Resource.HyperbolicExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="sinh" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sinh(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SinhToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="cosh" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>cosh(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CoshToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="tanh" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>tanh(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.TanhToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="coth" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>coth(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CothToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="arsinh" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sinh<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArsinhToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="arcosh" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>cosh<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArcoshToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="artanh" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>tanh<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArtanhToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="arcoth" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>coth<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArcothToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Tag="sech" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sech(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SechToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Tag="csch" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>csch(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CschToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="2" Tag="arsech" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>sech<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArsechToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="3" Tag="arcsch" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>csch<Run BaselineAlignment="Top" FontSize="12">-1</Run>(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ArcschToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="matrixToolBar" Header="{x:Static res:Resource.MatrixExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="det" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>det(A)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.DetToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="transpose" Click="InsertFunc_Click">
                            <Rectangle Fill="{StaticResource transpose}" Width="38" Height="32" />
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.TransposeToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="inverse" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>A<Run BaselineAlignment="Top" FontSize="12">-1</Run></TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.InverseToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="statisticalToolBar" Header="{x:Static res:Resource.StatisticalExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="min" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>min(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.MinToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="max" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>max(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.MaxToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="avg" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>avg(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.AvgToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="count" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>count(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.CountToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="var" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>var(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.VarToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="varp" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>varp(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.VarpToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="stdev" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>stdev(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.StdevToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="stdevp" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>stdevp(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.StdevpToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Tag="sum" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>∑</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SumToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Tag="product" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>∏</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ProductToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="complexNumberToolBar" Header="{x:Static res:Resource.ComplexNumberExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="re" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>Re(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ReToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="im" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>Im(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ImToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="phase" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>Phase(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.PhaseToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="conjugate" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>Conjugate(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ConjugateToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        
                        <Button Grid.Row="1" Grid.Column="0" Tag="reciprocal" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>Reciprocal(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ReciprocalToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="bitwiseToolBar" Header="{x:Static res:Resource.BitwiseExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="~" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>not</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.NotToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="&amp;" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>and</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.AndToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="|" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>or</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.OrToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="xor" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>xor</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.XOrToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="=>" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>→</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ImplicationToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="&lt;=>" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>↔</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.EqualityToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="nor" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>↓</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.NOrToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="nand" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>|</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.NAndToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="progToolBar" Header="{x:Static res:Resource.ProgExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="==" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>==</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.EqualToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="!=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>!=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.NotEqualToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="&amp;&amp;" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>&amp;&amp;</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ConditionalAndToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="||" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>||</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ConditionalOrToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="&lt;" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>&lt;</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.LessThanToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="&gt;" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>&gt;</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.GreaterThanToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="2" Tag="&lt;=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>&lt;=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.LessOrEqualToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="3" Tag="&gt;=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>&gt;=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.GreaterOrEqualToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Tag="+=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>+=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.AddAssignToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Tag="-=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>-=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SubAssignToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="2" Tag="*=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>*=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.MulAssignToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="3" Tag="/=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>/=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.DivAssignToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="3" Grid.Column="0" Tag="if" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>if()</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.IfToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="3" Grid.Column="1" Tag="for" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>for()</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.ForToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="3" Grid.Column="2" Tag="while" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>while()</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.WhileToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="constantsMathToolBar" Header="{x:Static res:Resource.ConstantsExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag="π" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>π</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="e" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>e</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="true" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>True</TextBlock>
                            </Viewbox>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="false" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>False</TextBlock>
                            </Viewbox>
                        </Button>
                    </Grid>
                </Expander>
                <Expander x:Name="additionalMathToolBar" Header="{x:Static res:Resource.AdditionalMathExpanderHeader}">
                    <Grid Margin="0,4,0,2" TextBlock.FontSize="18">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Tag=":=" Click="InsertChar_Click">
                            <Viewbox>
                                <TextBlock>:=</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.DefToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="1" Tag="undef" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>undef(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.UndefToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="0" Grid.Column="2" Tag="deriv" Click="InsertDoubleArgFunc_Click">
                            <Rectangle Fill="{StaticResource deriv}" Width="20" Height="20" />
                        </Button>
                        <Button Grid.Row="0" Grid.Column="3" Tag="simplify" Click="InsertFunc_Click">
                            <Viewbox>
                                <TextBlock>simplify(x)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.SimplifyToolTip}" />
                            </Button.ToolTip>
                        </Button>

                        <Button Grid.Row="1" Grid.Column="0" Tag="gcd" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>gcd(a, b)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.GCDToolTip}" />
                            </Button.ToolTip>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="1" Tag="lcm" Click="InsertDoubleArgFunc_Click">
                            <Viewbox>
                                <TextBlock>lcm(a, b)</TextBlock>
                            </Viewbox>
                            <Button.ToolTip>
                                <ToolTip Content="{x:Static res:Resource.LCMToolTip}" />
                            </Button.ToolTip>
                        </Button>
                    </Grid>
                </Expander>
            </StackPanel>
        </ScrollViewer>

        <ribbon:StatusBar Grid.Row="3" Grid.ColumnSpan="2">
            <ribbon:StatusBarItem HorizontalAlignment="Left" VerticalAlignment="Center">
                <TextBlock x:Name="statusBox" />
            </ribbon:StatusBarItem>
        </ribbon:StatusBar>
    </Grid>
</ribbon:RibbonWindow>
